{layout name="main"/}
<style>
    .modal-backdrop,.fade,.in { display: none;}
</style>
<div class="wrapper wrapper-content animated fadeInUp">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox">

                <div class="ibox-title">
                    <h5>区域代理列表</h5>

                </div>

                <div class="ibox-content">
                    <div class="row m-b-sm m-t-sm">
                        <div class="col-sm-4">
                            <a class="btn{if condition="$type eq 'all'"} btn-info {else} btn-default {/if}btn-sm" href="{:url('admin/Agent/showlist', [],'')}/">
                               <i class="fa fa-list"></i>
                                    所有</a>
                                <a class="btn{if condition="$type eq 'ok'"} btn-info {else} btn-default {/if}btn-sm" href="{:url('admin/Agent/showlist', [],'')}/type/ok/keyword/{$keyword}"><i class="fa fa-check-square"></i> 已审核</a>
                                    <a class="btn{if condition="$type eq 'error'"} btn-info {else} btn-default {/if}btn-sm" href="{:url('admin/Agent/showlist', [],'')}/type/error/keyword/{$keyword}"><i class="fa fa-minus-square"></i> 未审核</a>
                                    </div>
                                    <div class="col-sm-8">
                                        <div class="input-group">
                                            <input type="text" placeholder="搜索(会员编号,会员昵称,代理区域)" class="input-sm form-control" name=keyword value="{$keyword}"> <span class="input-group-btn">
                                                <button type="button" class="btn btn-sm btn-primary" onclick="search()">搜索</button> </span>
                                        </div>
                                    </div>
                                </div>
                                <div class="project-list">
                                    <table class="table table-striped table-bordered table-hover dataTables-example dataTable" id="DataTables_Table_0" aria-describedby="DataTables_Table_0_info">
                                        <thead>
                                            <tr role="row">
                                                <!--                                    <th>选择</th>-->
                                                <th  style="width: 12%;">会员编号</th>
                                                <th style="width: 10%;">会员昵称</th>
                                                <th  style="width: 12%;">申请时间</th>
                                                <th  style="width: 12%;">确认时间</th>
                                                <th  style="width: 10%;">代理区域</th>
                                                <th  style="width: 5%;">状态</th>
                                                <th  style="width: 10%;">操作人</th>
                                                <th  style="width: 20%;">操作</th>
                                            </tr>
                                        </thead>

                                        <!--                            <tbody><tr class="no-records-found"><td colspan="8">没有找到匹配的记录</td></tr></tbody>-->

                                        <tbody>
                                            {:table_empty_list($list,'暂无数据!',8)}
                                            {volist name="list" id="vo"}
                                            <tr class="gradeA odd">
                                                <!--                                    <td>
                                                                                        <input type="checkbox"  class="i-checks" name="input[]">
                                                                                    </td>-->
                                                <td class=" ">{$vo->user->user_uniid}</td>
                                                <td class=" ">{$vo->user->user_name}</td>
                                                <td class="center ">{$vo->create_time}</td>
                                                <td class="center ">{$vo->confirm_time|default="/"}</td>
                                                <td class="center ">{$vo->location}</td>
                                                <td class="center">
                                                    {if condition="$vo.application_status eq '未审核'"}
                                                    <span class="badge badge-danger">{$vo->application_status}</span>
                                                    {elseif condition="$vo.application_status eq '已通过'"}
                                                    <span class="badge badge-primary">{$vo->application_status}</span>
                                                    {/if}
                                                </td>
                                                <td class="center ">{$vo->confirmed_user->user_name}</td>
                                                <td class="center">
                                                    <button class="btn btn-warning btn-xs"  data-toggle="modal" data-target="#myModal{$vo->agent_application_id}">查看备注</button>
                                                    {if condition="$vo.application_status eq '未审核'"}
                                                    <button class="btn btn-primary btn-xs" onclick="caozuo('确认通过该会员申请代理吗？', {$vo->agent_application_id},'ok')"><i class="fa fa-check-square-o"></i> 通过 </button>
                                                    <button class="btn btn-danger btn-xs"  onclick="caozuo('确认不通过该会员申请吗？', {$vo->agent_application_id},'error')"><i class="fa fa-times"></i> 不通过 </button>

                                                    {/if}

                                     

                                                </td>
                                            </tr>
                                            {/volist}
                                            <!--                                <tr class="gradeA even">
                                                                                <td> <input type="checkbox"  class="i-checks" name="input[]"></td>
                                                                                <td class=" ">OKD001</td>
                                                                                <td class=" ">徐军0791</td>
                                                                                <td class="center ">2016年3月3日</td>
                                                                                <td class="center ">2016年3月3日</td>
                                                                                <td class="center ">江西 九江 星子县</td>
                                                                                <td class="center"><span class="badge badge-primary">已审核</span></td>
                                                                                <td class="center">
                                                                                    <button class="btn btn-warning btn-xs" onclick="setava(1, this)">查看备注</button>
                                                                            
                                                                                </td>
                                                                            </tr>-->
                                        </tbody>

                                    </table>
                                    <!--                        <div class="row">
                                                                <div class="col-sm-6 m-t-sm"> 
                                                                    <button class="btn btn-primary btn-xs" id="selectAll" onclick="deletearticle(1)"><i class="fa fa-check"></i> 全选 </button>
                                                                    <button class="btn btn-warning btn-xs" id="deleteAll" onclick="deletearticle(1)"><i class="fa fa-trash"></i> 批量删除 </button>
                                                                </div>
                                                            </div>-->
                                    <div class="row">
                                        <div class="col-sm-6">
                                            <div class="dataTables_info" id="DataTables_Table_0_info" role="alert" aria-live="polite" aria-relevant="all">
                                                每页显示 {:getPageSize()} 项，共 {$list->toArray()['total']} 项</div></div>
                                        <div class="col-sm-6">
                                            <div class="dataTables_paginate paging_simple_numbers" id="DataTables_Table_0_paginate">
                                                {$list->render()}

                                            </div>

                                        </div>
                                    </div>
                                </div>

                            </div>
                        </div>
                    </div>
                </div>
            </div>


  {volist name="list" id="vo"}
               <div class="modal inmodal fade" id="myModal{$vo->agent_application_id}" tabindex="-1" role="dialog"  aria-hidden="true">
                                                        <div class="modal-dialog modal-sm">
                                                            <div class="modal-content">
                                                                <div class="modal-header">
                                                                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                                                                    <h4 class="modal-title">备注信息</h4>
                                                                </div>
                                                                <div class="modal-body">
                                                                    <p>

                                                                        {$vo->comments|default="会员未填写"}


                                                                    </p>
                                                                </div>
                                                                <div class="modal-footer">
                                                                    <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>

                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
       {/volist}
            <script>
                $(document).ready(function () {
                    $(".i-checks").iCheck({checkboxClass: "icheckbox_square-green", radioClass: "iradio_square-green", });
                    $("#selectAll").on('click', function (event) { //如果是选中，点击后则为不选中 
                        $(".i-checks").iCheck('check');
                    });


                    $("#deleteAll").click(function () {
                        swal({
                            title: "您确定要删除这条信息吗",
                            text: "删除后将无法恢复，请谨慎操作！",
                            type: "warning",
                            showCancelButton: true,
                            confirmButtonColor: "#DD6B55",
                            confirmButtonText: "删除",
                            closeOnConfirm: false,
                            cancelButtonText: "取消",
                        }, function () {
                            swal("删除成功！", "您已经永久删除了这条信息。", "success");
                        });
                    });


                });

                function caozuo(title, id,type) {

     
                    swal({title: title,
                        text: "",
                        type: "input",
                        showCancelButton: true,
                        closeOnConfirm: false,
                        cancelButtonText: "取消",
                        confirmButtonText: "确认",
                        animation: "slide-from-top",
                        inputPlaceholder: "输入备注信息\n\
"}, function (inputValue) {
                        if (inputValue === false)
                            return false;
                        if (inputValue === "") {
                            swal.showInputError("输入备注信息");
                            return false;
                        }
                   
                        post({
                            url: "{:url('admin/Agent/caozuo',[],'')}/id/" + id+ '/type/' + type+ '/value/' + inputValue,
                            success: function (res) {
                                swal({title: 'success', text: res.message, type: "success"}, function () {
                                    reload();
                                });
                            },
                            error: function (error) {
                                swal("错误", JSON.parse(error.responseText).message, "error");
                            }
                        });

                    });

                }

                function search() {
                    var keyword = $("input[name=keyword]").val();


                    toUrl("{:url('admin/Agent/showlist', [],'')}/keyword/" + keyword);
                    //+ "/startdate/" + startdate + "/enddate/" + enddate
                }
            </script>